package com.ctsi.product.service;

import com.ctsi.commons.util.UtilValidate;
import com.ctsi.commons.util.id.UUIDGenerator;
import com.ctsi.framework.mybatis.support.MybatisGenericDao;
import com.ctsi.product.entity.ProductTypeName;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ProductTypeNameService {
    private static final Logger logger= LoggerFactory.getLogger(ProductTypeNameService.class);
    @Autowired
    private MybatisGenericDao dao;

//    添加产品类型和名称
    public int insertProductLibrary(ProductTypeName productTypeName){
        if(UtilValidate.isEmpty(productTypeName.getId()))
            productTypeName.setId(UUIDGenerator.getId());
        logger.debug("insert {}",productTypeName);
        return dao.insert(productTypeName);
    }
    /**
     * 删除ProductTypeName对象
     */
    public int removeProductTypeName(String id){
        if(UtilValidate.isNotEmpty(id))
            return dao.delete(ProductTypeName.class.getName()+".delete", id);
        return 0;
    }
}
